import request from '../index'

//登录接口
export const reqUserLogin = ({id, phone, password, nickname, user_avatar}) => request({
    url: '/api/login',
    method: 'POST',
    data: {
        id,
        phone,
        password,
        nickname,
        user_avatar
    }
})

//注册接口
export const reqUserRegister = ({phone, nickname, password, confirmPassword}) => request({
    url: '/api/register',
    method: 'POST',
    data: {
        phone,
        nickname,
        password,
        confirmPassword,
    }
})

//写笔记接口
export const reqWriteNode = ({user_id, Info}) => request({
    url: '/note/writeNote',
    method: 'POST',
    data: {
        user_id, Info
    }
})

//获取笔记列表信息的接口
export const reqGetNoteList = ({user_id}) => request({
    url: '/note/getNoteList',
    method: 'GET',
    params: {
        user_id
    }
})
//删除笔记的接口
export const reqDeleteNote = ({note_id}) => request({
    url: '/note/deleteNote',
    method: 'GET',
    params: {
        note_id
    }
})

//获取文章列表信息的接口
export const reqArticleIntro = () => request({
    url: '/article/articleIntro',
    method: 'GET',
})

//用户发布文章的接口
export const reqPublishArticle = ({user_id, article}) => request({
    url: '/writeArticle/publishArticle',
    method: 'POST',
    data: {
        user_id, article
    }
})

//将文章存为草稿的接口
export const reqInsertDraft = ({nickname, user_id, draft}) => request({
    url: '/writeArticle/insertDraft',
    method: 'POST',
    data: {
        nickname, user_id, draft
    }
})

//获取文章信息的接口
export const reqArticleInfo = (id) => request({
    url: `/article/articleInfo/${id}`,
    method: 'GET',
    params: {
        id
    }
})

//删除文章信息的接口
export const reqDeleteMyArticle = ({nickname, article_id}) => request({
    url: `/article/deleteMyArticle`,
    method: 'POST',
    data: {
        nickname, article_id
    }
})

//获取草稿信息的接口
export const reqGetDraftList = ({user_id, nickname}) => request({
    url: `/draft/getDraftList`,
    method: 'GET',
    params: {
        user_id, nickname
    }
})

//发布草稿的接口
export const reqPublishDraft = ({nickname, draft_id, draftInfo}) => request({
    url: `/draft/publishDraft`,
    method: 'POST',
    data: {
        nickname, draft_id, draftInfo
    }
})

//发表评论接口
export const reqPublishComment = ({article_id, user_id, content}) => request({
    url: `/article/publishComment`,
    method: 'POST',
    data: {
        article_id, user_id, content
    }
})
export const reqReplyComment = ({article_id, user_id, content,parent_comment_id}) => request({
    url: `/article/replyComment`,
    method: 'POST',
    data: {
        article_id, user_id, content,parent_comment_id
    }
})
//获取一级评论信息接口
export const reqGetComment = (id) => request({
    url: `/article/comment/${id}`,
    method: 'GET',
    params: {
        id
    }
})

//获取用户信息接口
export const reqGetUsers = () => request({
    url: `/article/getUsers`,
    method: 'GET'
})
//获取课程列表信息的接口
export const reqGetCourseList = () => request({
    url: `/course/getCourseList`,
    method: 'GET',
})
//获取课程信息的接口
export const reqGetCourse = (course_id) => request({
    url: `/course/getCourse/${course_id}`,
    method: 'GET',
    params: {
        course_id
    }
})
//生成一个课程订单信息
/*
*   根据course_id找到是哪个课程
*
* */
export const reqGetCourseOrder = (course_id) => request({
    url: `/course/getCourseOrder/${course_id}`,
    method: 'GET',
    params: {
        course_id,
    }
})


//获取二维码以及支付状态
export const reqGetBuyCourseStatus = ({course_id, user_id}) => request({
    url: `/course/getCoursePayStatus`,
    method: 'GET',
    params: {
        course_id,
        user_id,
    }
})

//获取课程中心里的信息
export const reqGetMyCourseList = (user_id) => request({
    url: `/course/getMyCourseList`,
    method: 'GET',
    params: {
        user_id,
    }
})
//删除课程中心里我的订单信息
export const reqDeleteMyCourseOrder = ({order_id}) => request({
    url: `/course/deleteMyCourseOrder`,
    method: 'GET',
    params: {
        order_id,
    }
})


//获取活动的接口
export const reqGetActivityList = (page) => request({
    url: `/activity/getActivityList?page=${page}`,
    method: 'GET',
})
//参加活动的接口
export const reqAttendActivity = ({user_id, activity_id, fd}) => request({
    url: `/activity/attendActivity`,
    method: 'post',
    data: {
        user_id, activity_id, fd
    }
})
//获得我参加的活动的接口
export const reqGetMyActivity = (user_id) => request({
    url: `/activity/getMyActivity`,
    method: 'GET',
    params: {
        user_id
    }
})
//购买vip的接口
export const reqGetVipPayStatus = ({user_id, role}) => request({
    url: `/buy-vip/getVipPayStatus`,
    method: 'post',
    data: {
        user_id, role
    }
})
//获取商品的接口
export const reqGetShopping = () => request({
    url: `/shop/getShopping`,
    method: 'GET',
})

//获取商品信息的接口
export const reqGetShoppingById = (shop_id) => request({
    url: `/shop/getShoppingById/${shop_id}`,
    method: 'GET',
    params:{
        shop_id
    }
})
//获取购买商品状态的接口
export const reqGetBuyShoppingStatus = ({shopping_id, user_id}) => request({
    url: `/shop/getShoppingPayStatus`,
    method: 'GET',
    params: {
        shopping_id,
        user_id,
    }
})
//生成商品订单的接口
export const reqGetShoppingOrder = ({shopping_id, user_id}) => request({
    url: `/shop/getShoppingOrder`,
    method: 'GET',
    params: {
        shopping_id,
        user_id,
    }
})

//获取我的商品的接口
export const reqGetMyShopping = ({user_id}) => request({
    url: `/shop/getMyShopping`,
    method: 'GET',
    params: {
        user_id,
    }
})


//点赞接口
export const reqLike = ({user_id, article_id, cancel}) => request({
    url: `/article/like`,
    method: 'POST',
    data: {
        user_id, article_id, cancel
    }
})
//获取文章赞数接口
export const reqGetArticleLikes = () => request({
    url: `/article/getArticleLikes`,
    method: 'GET',
})
//判断是否点赞过
export const reqGetJudgeLike = ({user_id, article_ids}) => request({
    url: `/article/judgeLike`,
    method: 'POST',
    headers: {
        'Content-Type': 'application/json'
    },
    data: {
        user_id, article_ids
    }
})

//获取文件
export const reqGetFiles = () => request({
    url: `/download/getFiles`,
    method: 'GET',
})
//下载文件
export const reqDownLoadFile = ({filename}) => request({
    url: `/download/downloadFile/${filename}`,
    method: 'GET',
    responseType:'blob',
    headers: {
        'Content-Type': 'application/octet-stream'
    },
})
//保存文件
export const reqSaveFiles = ({user_id,files,sort}) => request({
    url: `/download/saveFiles`,
    method: 'post',
    data:{
        user_id,files,sort
    }
})

